import { segment } from "oicq";
import fetch from "node-fetch";
import fs from "fs";
import common from'../../lib/common/common.js'
import { url } from "inspector";
let url1
let i
export class example extends plugin {
    constructor() {
      super({
        /** 功能名称 */
        name: '樱花动漫',
        /** 功能描述 */
        dsc: '樱花动漫',
        /** https://oicqjs.github.io/oicq/#events */
        event: 'message',
        /** 优先级，数字越小等级越高 */
        priority: 1,
        rule: [
          {
            /** 命令正则匹配 */
            reg: '#樱花 (.*)$',
            /** 执行方法 */
            fnc: 'yh'
          },
          {
            /** 命令正则匹配 */
            reg: '#看(.*)$',
            /** 执行方法 */
            fnc: 'yh1'
          },
          
        ]
      })
    }  async yh(e) {
        let msg = e.msg.replace('#樱花 ','')
         url1 = `http://q.dsbs.fun/api/yhdm?msg=${msg}`
        let res = await fetch(url1)
        
        res= await res.text()
        console.log(res)
        e.reply(res+'\n例：#看1') 
      i=1 
   
    }async yh1(e) {if(i!==1){return false}else{
      let msg = e.msg.replace('#看','')
      let url2 = url1+`&b=${msg}`
      
      console.log(url2)
      let res = await fetch(url2)
      res = await res.text()
      res=decodeURIComponent(res)
      e.reply(res)
      i=0
    }}}